﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CheckingDriveSupport
{
  class Program
  {

    //This script examines the burn device characteristics such as 
    //product ID, product revision level, feature set, and profiles. 
    //Copyright (C) Microsoft Corp. 2006

    // Constants
    const int IMAPI_FEATURE_PAGE_TYPE_DVD_DASH_WRITE = 47;

    static void Main(string[] args)
    {

      dynamic Index;                // Index to recording drive.
      dynamic recorder;             // Recorder object
      dynamic Path;                 // Directory of files to burn
      dynamic Stream;               // Data stream for burning device

      Index = 1;                // Second drive on the system

      // Create a DiscMaster2 object to connect to CD/DVD drives.
      dynamic g_DiscMaster;
      g_DiscMaster = new IMAPI2.MsftDiscMaster2();

      // Create a DiscRecorder object for the specified burning device.
      dynamic uniqueId;
      recorder = new IMAPI2.MsftDiscRecorder2();
      uniqueId = g_DiscMaster.Item(Index);
      recorder.InitializeDiscRecorder(uniqueId);

      // *** - Formatting to display recorder info
      Console.WriteLine("--------------------------------------------------");
      Console.WriteLine(" ActiveRecorderId: " + recorder.ActiveDiscRecorder);
      Console.WriteLine("        Vendor Id: " + recorder.VendorId);
      Console.WriteLine("       Product Id: " + recorder.ProductId);
      Console.WriteLine(" Product Revision: " + recorder.ProductRevision);
      Console.WriteLine("       VolumeName: " + recorder.VolumeName);
      Console.WriteLine("   Can Load Media: " + recorder.DeviceCanLoadMedia);
      Console.WriteLine("    Device Number: " + recorder.LegacyDeviceNumber);

      foreach (var mountPoint in recorder.VolumePathNames)
      {
        Console.WriteLine("      Mount Point: " + mountPoint);
      }

      Console.WriteLine("Supported Features"); //in _IMAPI_FEATURE_PAGE_TYPE 
      foreach (var supportedFeature in recorder.SupportedFeaturePages)
      {
        if (supportedFeature == IMAPI_FEATURE_PAGE_TYPE_DVD_DASH_WRITE)
        {
          Console.WriteLine("    Feature: " + supportedFeature + "  Drive supports DVD-RW.");
        }
        else
        {
          Console.WriteLine("    Feature: " + supportedFeature);
        }
      }

      Console.WriteLine("Current Features"); // in _IMAPI_FEATURE_PAGE_TYPE
      foreach (var currentFeature in recorder.CurrentFeaturePages)
      {
        Console.WriteLine("    Feature: " + currentFeature);
      }

      Console.WriteLine("Supported Profiles"); //in _IMAPI_PROFILE_TYPE
      foreach (var supportedProfile in recorder.SupportedProfiles)
      {
        Console.WriteLine("    Profile: " + supportedProfile);
      }

      Console.WriteLine("Current Profiles"); // in _IMAPI_PROFILE_TYPE
      foreach (var currentProfile in recorder.CurrentProfiles)
      {
        Console.WriteLine("    Profile: " + currentProfile);
      }

      Console.WriteLine("Supported Mode Pages"); // in  _IMAPI_MODE_PAGE_TYPE
      foreach (var supportedModePage in recorder.SupportedModePages)
      {
        Console.WriteLine("    Mode Page: " + supportedModePage);
      }

      Console.WriteLine();
      Console.WriteLine("----- Finished content -----");

      Console.ReadKey();

    }
  }
}
